export default {
  bind: function(el) {
    // 兼容原生元素和非原生组件
    const input = el.nodeName === 'INPUT' ? el : el.getElementsByTagName('input')[0]
    const keyFn = (e) => {
      input.value = input.value.replace(/(^[^1-9])|[^\d]/g, '')
      // 解决vue数据响应问题
      const ev = document.createEvent('HTMLEvents')
      ev.initEvent('input', true, true)
      input.dispatchEvent(ev)
    }
    input.onkeyup = keyFn
    input.onblur = keyFn
  }
}
